package com.jxw.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.jxw.domain.StudyRecord;
import com.jxw.launcher.R;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/* loaded from: classes.dex */
public class JiLuAdapter extends BaseAdapter {
    private int durationAll;
    private Context mContext;
    StudyRecord record;
    private ViewHolder holder = null;
    private List<StudyRecord> mList = new ArrayList();
    private List<String> mListTemp = new ArrayList();

    @Override // android.widget.Adapter
    public long getItemId(int i) {
        return i;
    }

    public JiLuAdapter(Context context, List<StudyRecord> list) {
        this.durationAll = 0;
        this.mContext = context;
        for (int i = 0; i < list.size(); i++) {
            if (!this.mListTemp.contains(list.get(i).getName())) {
                this.durationAll = 0;
                this.record = new StudyRecord();
                for (int i2 = 0; i2 < list.size(); i2++) {
                    if (list.get(i).getName().equals(list.get(i2).getName())) {
                        this.durationAll += Integer.parseInt(list.get(i2).getDuration());
                    }
                }
                this.record.setName(list.get(i).getName());
                this.record.setExitTime(list.get(i).getExitTime());
                if (this.durationAll == 0) {
                    this.record.setDuration(list.get(i).getDuration() + "");
                } else {
                    this.record.setDuration(this.durationAll + "");
                }
                this.mList.add(this.record);
                this.mListTemp.add(list.get(i).getName());
            }
        }
        sortTime(this.mList, false);
    }

    public static final List<StudyRecord> sortTime(List<StudyRecord> list, final boolean z) {
        Collections.sort(list, new Comparator<StudyRecord>() { // from class: com.jxw.adapter.JiLuAdapter.1
            @Override // java.util.Comparator
            public int compare(StudyRecord studyRecord, StudyRecord studyRecord2) {
                int parseInt = Integer.parseInt(studyRecord.getDuration()) - Integer.parseInt(studyRecord2.getDuration());
                return z ? parseInt : -parseInt;
            }
        });
        return list;
    }

    @Override // android.widget.Adapter
    public int getCount() {
        return this.mList.size();
    }

    @Override // android.widget.Adapter
    public Object getItem(int i) {
        return this.mList.get(i);
    }

    @Override // android.widget.Adapter
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (view == null) {
            view = LayoutInflater.from(this.mContext).inflate(R.layout.item_jilu, (ViewGroup) null);
            this.holder = new ViewHolder();
            this.holder.tv_learncontent = (TextView) view.findViewById(R.id.tv_learncontent);
            this.holder.tv_totaltime = (TextView) view.findViewById(R.id.tv_totaltime);
            this.holder.tv_updatetime = (TextView) view.findViewById(R.id.tv_updatetime);
            view.setTag(this.holder);
        } else {
            this.holder = (ViewHolder) view.getTag();
        }
        this.holder.tv_learncontent.setText(this.mList.get(i).getName());
        this.holder.tv_totaltime.setText(this.mList.get(i).getDuration());
        this.holder.tv_updatetime.setText(this.mList.get(i).getExitTime());
        return view;
    }

    /* loaded from: classes.dex */
    public class ViewHolder {
        private TextView tv_learncontent;
        private TextView tv_totaltime;
        private TextView tv_updatetime;

        public ViewHolder() {
        }
    }
}
